package cn.edu.tsinghua.smxq.mobilecity.service;

import java.sql.SQLException;
import java.util.List;

import cn.edu.tsinghua.smxq.mobilecity.dao.BusSearchDAO;
import cn.edu.tsinghua.smxq.mobilecity.dao.ElectricityRecordDAO;
import cn.edu.tsinghua.smxq.mobilecity.dao.StockSearchDAO;
import cn.edu.tsinghua.smxq.mobilecity.dao.WaterRecordDAO;
import cn.edu.tsinghua.smxq.mobilecity.po.BusSearch;
import cn.edu.tsinghua.smxq.mobilecity.po.ElectricityRecord;
import cn.edu.tsinghua.smxq.mobilecity.po.StockSearch;
import cn.edu.tsinghua.smxq.mobilecity.po.WaterRecord;

public class InquiryLogService {
	private BusSearchDAO busSearchDAO;
	private StockSearchDAO stockSearchDAO;
	private ElectricityRecordDAO electricityRecordDAO;
	private WaterRecordDAO waterRecordDAO;
	
	

	public InquiryLogService(){
		busSearchDAO=new BusSearchDAO();
		stockSearchDAO=new StockSearchDAO();
		electricityRecordDAO=new ElectricityRecordDAO();
		waterRecordDAO=new WaterRecordDAO();
	}

	public WaterRecordDAO getWaterRecordDAO() {
		return waterRecordDAO;
	}


	public void setWaterRecordDAO(WaterRecordDAO waterRecordDAO) {
		this.waterRecordDAO = waterRecordDAO;
	}

	public ElectricityRecordDAO getElectricityRecordDAO() {
		return electricityRecordDAO;
	}


	public void setElectricityRecordDAO(ElectricityRecordDAO electricityRecordDAO) {
		this.electricityRecordDAO = electricityRecordDAO;
	}


	public BusSearchDAO getBusSearchDAO() {
		return busSearchDAO;
	}



	public void setBusSearchDAO(BusSearchDAO busSearchDAO) {
		this.busSearchDAO = busSearchDAO;
	}



	public StockSearchDAO getStockSearchDAO() {
		return stockSearchDAO;
	}



	public void setStockSearchDAO(StockSearchDAO stockSearchDAO) {
		this.stockSearchDAO = stockSearchDAO;
	}
	

	public int saveBusSearch(BusSearch busSearch) throws SQLException{
		if(busSearchDAO.saveBusSearch(busSearch))
			return 1;
		else
			return -1;	
	}

	public int saveStockSearch(StockSearch stockSearch) throws SQLException{
		if(stockSearchDAO.saveStockSearch(stockSearch))
			return 1;
		else
			return -1;
		
	}
	
	public List<ElectricityRecord> getAllElectricityRecordByUserId(int userId) throws SQLException{
		return electricityRecordDAO.getAllByUserId(userId);	
	}
	
	public ElectricityRecord getOneElectricityRecordByUserId(int userId,int month) throws SQLException{
		return electricityRecordDAO.getOneByUserId(userId,month);	
	}
	
	public List<WaterRecord> getAllWaterRecordByUserId(int userId) throws SQLException{
		return waterRecordDAO.getAllByUserId(userId);	
	}
	
	public WaterRecord getOneWaterRecordByUserId(int userId,int month) throws SQLException{
		return waterRecordDAO.getOneByUserId(userId,month);	
	}
}
